package com.xw.unification.annotations;

import com.xw.unification.constant.UnificationConstant.SignatureCheckConstant;
import com.xw.unification.enums.SignatureOperation;
import com.xw.unification.enums.SortType;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 签名验证规则定义
 *
 * @author qiwei
 * @date 2023-8-14 15:38:10
 * @since v1.0.0
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface SignatureCheckDefinition {

    /**
     * 是否有 signature key
     * @return boolean
     */
    boolean hasSignatureKey() default SignatureCheckConstant.DEFAULT_HAS_SIGNATURE_KEY;

    /**
     * signature key 是否参与排序
     * @return boolean
     */
    boolean signatureKeyInSort() default SignatureCheckConstant.DEFAULT_SIGNATURE_KEY_IN_SORT;

    /**
     * signature key 参数名
     * @return String
     */
    String signatureKeyName() default SignatureCheckConstant.DEFAULT_SIGNATURE_KEY_NAME;

    /**
     * signature 校验值参数名
     * @return String
     */
    String validationSignatureName() default SignatureCheckConstant.DEFAULT_VALIDATION_SIGNATURE_NAME;

    /**
     * 是否忽略值为空的参数
     * @return boolean
     */
    boolean ignoreEmptyValue() default SignatureCheckConstant.DEFAULT_IGNORE_EMPTY_VALUE;

    /**
     * 验签异常枚举名, 仅当 unified-response enable 且配置了 result 枚举类时有效
     * @return String
     */
    String checkErrorEnumName() default "";

    /**
     * 参数名排序规则
     * @return SortType
     */
    SortType paramNameSort() default SortType.ASC;

    /**
     * 忽略的参数名
     * @return String[]
     */
    String[] ignoreParamNames() default {};

    /**
     * Query String 处理
     * @return SignatureOperation[]
     */
    SignatureOperation[] operations() default {SignatureOperation.MD5, SignatureOperation.UPPER};

}
